package com.lifa.controller;

import com.lifa.dao.ShangpinFenleiDao;
import com.lifa.entity.ShangpinFenlei;
import com.lifa.service.ShangpinFenleiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
/**
 * 123
 */
@Controller
@RequestMapping("/shangpin")
@Scope("prototype")
public class ShangpinFenleiController {
    @Autowired
    private ShangpinFenleiDao shangpinFenleiDao;
    @Autowired
    private ShangpinFenleiService shangpinFenleiService;

    /**
     * 查询全部
     * @return
     */
    @RequestMapping("/shangpin1")
    @ResponseBody
    public List<ShangpinFenlei> list(){
        return shangpinFenleiDao.query1();
    }

    /**
     * 根据商品id删除商品信息
     * @param shangpinFenlei_Id
     * @return
     */
    @RequestMapping("/shanchu")
    @ResponseBody
    public int shanchu(int shangpinFenlei_Id){
        return shangpinFenleiService.delete(shangpinFenlei_Id);
    }

    /**
     * 添加商品
     * @param shangpinFenlei
     * @return
     */
    @RequestMapping("/tiajia")
    @ResponseBody
    public int tiajia(ShangpinFenlei shangpinFenlei){
       return shangpinFenleiService.insert(shangpinFenlei);
    }

    /**
     * 获取到商品分类id
     * @param shangpinFenlei_Id
     * @return
     */
    @RequestMapping("/queryId")
    @ResponseBody
    public ShangpinFenlei queryId(int shangpinFenlei_Id){
        return shangpinFenleiService.queryId(shangpinFenlei_Id);
    }

    /**
     * 根据商品分类id修改信息
     * @param shangpinFenlei
     * @return
     */
    @RequestMapping("/xiugai")
    @ResponseBody
    public int xiugai(ShangpinFenlei shangpinFenlei){
        return shangpinFenleiService.update(shangpinFenlei);
    }
}
